package com.study.license.core.model;

import cn.hutool.core.io.FileUtil;
import de.schlichtherle.license.DefaultKeyStoreParam;

import java.io.IOException;
import java.io.InputStream;

public class WonderKeyStoreParam extends DefaultKeyStoreParam {
    private final String resource;

    /**
     * Constructs a new instance.
     *
     * @param clazz    Used to retrieve the classloader required to load the
     *                 keystore as a resource.
     * @param resource The resource identifier for the keystore
     *                 to be returned by {@link #getStream()}.
     * @param alias    The alias for the key entry in the key store
     *                 to be returned by {@link #getAlias()}.
     * @param storePwd The key store password
     *                 to be returned by {@link #getStorePwd()}.
     * @param keyPwd   The password for the private key in the key store entry
     *                 to be returned by {@link #getStorePwd()}.
     */
    public WonderKeyStoreParam(Class clazz, String resource, String alias, String storePwd, String keyPwd) {
        super(clazz, resource, alias, storePwd, keyPwd);
        this.resource = resource;
    }

    @Override
    public InputStream getStream() {
        return FileUtil.getInputStream(resource);
    }
}
